package com.hspedu.exception_;


import java.util.Scanner;

/**
 * @author 谷其昊
 * @version 1.0
 * @date 2022/1/30
 * @time 19:29
 */
public class ExceptionExercise02 {
    public static void main(String[] args) {
        boolean flag = true;
        //Scanner scanner;
        Scanner scanner = new Scanner(System.in);
        do {
            try {
                System.out.println("请输入一个整数");
                int num = scanner.nextInt();
                flag = false;
            } catch (Exception e) {
                System.out.println("输入不合法，请重新输入");
                scanner.next();
            }
        }while (flag);
    }
}
